#ifndef _entity_h__
#define _entity_h__
#include <math/matrix44.h>
#include <resource\iserialisable.h>

namespace gecko
{

	//---------------------------------------------------------------------------------------------

	// base class for all game entities
	class Entity : public ISerialisable
	{
	public:
		RTTI_DECL(Entity)

		// serialisation
		BEGIN_DATAMAP(Entity, ISerialisable)
			REGISTER_BOOL(m_isAlive)
			REGISTER_MATRIX44(m_transform)
		END_DATAMAP

		// the state of the update
		enum UpdateReturn
		{
			UpdateReturn_KeepAlive,
			UpdateReturn_KillMe,
		};

		// constructor
		Entity();

		// destructor
		virtual ~Entity();

		// set the transform matrix
		void SetTransform(const Matrix44 & transform);

		// get the transform matrix
		void GetTransform(Matrix44 & transform) const;

		// is the entity alive?
		bool IsAlive();

		// called when the entity is killed
		virtual void OnDeath();

		// update the entity
		virtual UpdateReturn Update(float dt);

	protected:
		// is the entity alive
		bool			m_isAlive;
    
		// the transform of the entity
		Matrix44		m_transform;
	};

	//---------------------------------------------------------------------------------------------

	inline void Entity::SetTransform(const Matrix44 & transform)
	{
		m_transform = transform;
	}

	//---------------------------------------------------------------------------------------------

	inline void Entity::GetTransform(Matrix44 & transform) const
	{
		transform = m_transform;
	}

	//---------------------------------------------------------------------------------------------

	inline bool Entity::IsAlive()
	{
		return m_isAlive;
	}

	//---------------------------------------------------------------------------------------------

}

#endif // _entity_h__